package com.bw.dg.controller;
import com.bw.dg.pojo.Asset;
import com.bw.dg.service.AssetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@CrossOrigin
@RequestMapping("/asset")
public class AssetController {
    @Autowired
    private AssetService assetService;
    //资产种类
    @RequestMapping("/findAssetList")
    public List getAssetList(){
        List list=assetService.getAssetList();
        System.out.println(list);
        return list;
    }
    @RequestMapping("/findList")
    public List findList(){
        List list=assetService.findList();
        System.out.println(list);
        return list;
    }
    @RequestMapping("/findByXid")
    public List<Asset> findByXid(Long xid){
        return assetService.findByXid();
    }
   // @RequestMapping("/delete/{}")  @PathVariable
    @RequestMapping("/delete")
    public String  delete(@RequestParam("id") String id){
       String[] ids=id.split(",");
       for (String a:ids){
           assetService.del(a);
       }
       return "删除成功";
    }

    @RequestMapping("/add")
    public Asset add(@RequestBody Asset asset){
        return this.assetService.add(asset);
    }

    @RequestMapping("/findOne")
    public Asset findOne(Long id){
        return this.assetService.findOne(id);
    }
    @RequestMapping("/update")
    public String update(@RequestBody Asset asset){
        return this.assetService.update(asset);
    }
}
